<!--
 * @Description: 
 * @Author: ouyaping
 * @Date: 2025-10-10 22:36:51
 * @LastEditors: ouyaping
 * @LastEditTime: 2025-10-18 14:01:07
-->
<template>
    <div class="avue-contail" :class="{ 'avue--collapse': isCollapse, }">
        <div class="avue-layout" :class="{ 'avue-layout--horizontal': isHorizontal }">

            <div class="avue-main">
                <!-- 主体视图层 -->
                <div id="avue-view" v-if="isRefresh">
                    <router-view #="{ Component }">
                        <keep-alive :include="$store.getters.tagsKeep">
                            <component :is="Component" />
                        </keep-alive>
                    </router-view>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import { mapGetters } from "vuex";
import { validatenull } from 'utils/validate'
export default {
    name: "index",
    computed: {
        ...mapGetters(["isRefresh", "isCollapse",]),
    },
    created () {
        this.openMenu()
    },
    methods: {
        //打开菜单
        openMenu (item = {}) {
            this.$store.dispatch("GetMenu", item.parentId).then(data => {
                if (data.length !== 0) {
                    this.$router.$avueRouter.formatRoutes(data, true);
                }
                //当点击顶部菜单做的事件
                if (!validatenull(item)) {
                    let itemActive = {},
                        childItemActive = 0;
                    //vue-router路由
                    if (item.path) {
                        itemActive = item;
                    } else {
                        if (this.menu[childItemActive].length == 0) {
                            itemActive = this.menu[childItemActive];
                        } else {
                            itemActive = this.menu[childItemActive].children[childItemActive];
                        }
                    }
                    this.$store.commit('SET_MENU_ID', item);
                    this.$router.push({
                        path: itemActive.path
                    });
                }

            });
        },
    }
};
</script>
